<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>发布微博页面</h1>
<!--上传文件必须设置编码类型-->
<form action="" enctype="multipart/form-data">
    <input type="text" name="content" placeholder="微博正文">
    <input type="file" name="pic">
    <input type="button" value="发布" @click="send()">
</form>
<!--引入axios框架-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!--引入vue框架-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    let v =new Vue({
        el:"form",
        data:{},
        methods:{
            send:function () {
                let data= new FormData(document.querySelector("form"));
            //    发出上传文件的请求
                axios.post("send",data).then(function (response) {
                    if(response.data==0){
                        alert("请先登录！")
                        location.href="login.html";
                        return;
                    }
                    alert("发布完成！")
                    location.href="/";/*回到首页*/
                })
            }
        }
    })
</script>
</body>
</html>